<template>
	<view>
		<u-radio-group v-model="value" >
					<u-radio 
						@change="radioChange" 
						v-for="(item, index) in list" :key="index" 
						:name="item.type"
						:disabled="item.disabled"
					>
						
						<view class="line1">
							<image :src="item.name" class="line1"> </image>
							
						</view>
						
					</u-radio>
			
				</u-radio-group>
				<u-button @click="add">创建工厂</u-button>
				
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
								{
									type:'油气',
									name: "../../static/iconfont/油气.png",
									disabled: false
								},
								{
									name: "../../static/iconfont/零售商.png",
									disabled: false
								}
								// {
								// 	name: 'orange',
								// 	disabled: false
								// }
							],
							// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
							value: 'orange',
							type:'',
							merchant:{type:'',zid:this.$store.state.id}
			};
		},
		methods: {
				// 选中某个单选框时，由radio时触发
				radioChange(e) {
					 console.log(e);
					 this.merchant.type=e
					 
				},
				add(){
					const baseUrl="http://localhost:8888"
					uni.request({
						url:baseUrl+'/s/merchant/addtype',
						method:"POST",
						data:this.merchant,
					}).then(res=>{
						console.log(res)
						uni.navigateTo({
							url:'/pages/auth/auth'
						})
					})
				}
				
			}
	}
</script>

<style lang="scss">
.line1 {
		/* 长单词或字符串自动进行换行，下面两个二选一即可 */
		/* word-wrap: break-word; */
		word-break: break-all;
		display: block;
		width: 300px;
		height: 300px;
}
</style>
